function HandlePageContract(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options;
  
  this._customerId = (options && options.id) ? options.id : null;
  this._orderTrackId = (options && options.track) ? options.track : [];
  this._orderType = (options && options.type) ? options.type : null;
  
  this._createElements();
};

HandlePageContract.prototype._createElements = function() {
  this._loadData();
};

HandlePageContract.prototype._loadData = function() {
  this._customer = null;
  this._contract = null;
  this._retrieveCustomer();
  this._retrieveContract();
};

HandlePageContract.prototype._verifyData = function() {
  if (this._customer && this._contract) {
    this._updateElements();
  }
};

HandlePageContract.prototype._retrieveCustomer = function() {
  var _self = this;
  if (this._customerId) {
   /* new RequestUtils()._read('customer', null, 'd.oid =' + this._customerId, null, null, null, null, function(result, params) { _self._customer = (result.data.length == 1) ? result.data[0] : null;
                                                                                                                                _self._verifyData.call(_self);
                                                                                                                              }, null);
  */
   var args = '&oid=' + this._customerId; 
  new RequestUtils()._mysql('v1customer', args, function(result, params) { _self._customer = (result.data.length == 1) ? result.data[0] : null;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php'});       
  
  } else {
    this._customer = v1customer.instance();
    this._customer.createdDate = this._now;
    this._customer.sales = this._operator;
    this._verifyData();
  }
};

HandlePageContract.prototype._retrieveContract = function() {
  var _self = this;
  /*new RequestUtils()._read('contract', null, '', null, null, null, null, function(result, params) { _self._contract = (result.data.length > 0) ? result.data[0] : { content: '' };
                                                                                                    _self._verifyData.call(_self);
                                                                                                  }, null);
*/

  new RequestUtils()._mysql('contract', null, function(result, params) { _self._contract = (result.data.length > 0) ? result.data[0] : { content: '' };
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php'});     
};



HandlePageContract.prototype._updateElements = function() {
  var _self = this, span;
  
  this._gui.customerNo.appendChild(document.createTextNode(DlmanageUtils.customerId(this._customerId)));
  this._gui.brideName.appendChild(document.createTextNode(this._customer.bridename));
  this._gui.brideLn1.appendChild(document.createTextNode(this._customer.brideaddrLn1));
  this._gui.brideLn2.appendChild(document.createTextNode(this._customer.brideaddrLn2));
  this._gui.bridePhone.appendChild(document.createTextNode(this._customer.bridephone));
  this._gui.brideMobile.appendChild(document.createTextNode(this._customer.bridemobile));
  this._gui.brideEmail.appendChild(document.createTextNode(this._customer.brideemail));
  this._gui.groomName.appendChild(document.createTextNode(this._customer.groomname));
  this._gui.groomLn1.appendChild(document.createTextNode(this._customer.groomaddrLn1));
  this._gui.groomLn2.appendChild(document.createTextNode(this._customer.groomaddrLn2));
  this._gui.groomPhone.appendChild(document.createTextNode(this._customer.groomphone));
  this._gui.groomMobile.appendChild(document.createTextNode(this._customer.groommobile));
  this._gui.groomEmail.appendChild(document.createTextNode(this._customer.groomemail));

  this._gui.list.appendChild(MiscUtils.span(this._contract.content));
  new IContainerContract(this._gui.orderInfo, this._customer, this._options);

};

HandlePageContract.prototype._pay = function(gui, stage, rule) {
  var order = DlmanageUtils.order(this._customer.orders, this._orderTrackId);
  
  gui.payment.appendChild(document.createTextNode('Pay $' + (rule.perc * order.price).toFixed(2) + ' ' + rule.title + ' ' + rule.comment.toLowerCase()));
};